package com.edu.demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @ClassName: MvcConfig
 * @Description:
 * @Author: jxw
 * @Date: 2023-04-09
 */
@Configuration
public class MvcConfig extends WebMvcConfigurationSupport {

    // 磁盘目录
    @Value("${file.upload.path}")
    String path ;
    // 路径映射配置
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {


        // 将网页地址栏中的 /image/**  映射到  磁盘的某个目录下，以访问磁盘资源
        registry.addResourceHandler("/static/**").addResourceLocations("file:" + path);
        super.addResourceHandlers(registry);
    }


}
